package es

import (
	"bytes"
	"encoding/json"
	"github.com/elastic/go-elasticsearch/v7/esapi"
)

func SaveData(id, index string, data interface{}) error {
	dataBt, err := json.Marshal(data)
	if err != nil {
		return err
	}
	_, err = esClient.Index(index, bytes.NewReader(dataBt), func(request *esapi.IndexRequest) {
		request.DocumentID = id
	})
	return err
}
